import request from "@/utils/request";
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'

export const userInfoService = () => request.get('/api/auth/userInfo')
export const userLogin = query => request.get('/api/user/userLogin',{params:query})
export const userLoginByUsername = query => request.post('/api/user/loginByUsername',query)
export const userRegister = (query) => request.get('/api/user/userRegister',{params:query})
// 获取当前登录用户信息
export const getCurrentUserInfo = () => request.get('/api/user/getInfo')
// 保存修改后的用户信息
export const saveUpdatedUser = (updatedUser) => request.post('/api/user/saveUpdatedUser', updatedUser)
// 根据ID获取用户信息
export const getUserById = (id) => request.get(`/api/user/getById`, {params: {id}})
// 管理员条件查询用户列表
export const listUsers = (query) => request.get('/api/user/listUsers', {params: query})
// 管理员删除用户
export const deleteUserById = (id) => request.get(`/api/user/deleteById`, {params: {id}})
// 管理员冻结用户
export const freezeUserById = (id) => request.get(`/api/user/freezeById`, {params: {id}})
// 管理员解冻用户
export const unfreezeUserById = (id) => request.get(`/api/user/unfreezeById`, {params: {id}})
//根据id获取他人用户的基本信息
export const getOtherUserInfo = (id) => request.get(`/api/user/getOtherUserInfo`, {params: {id}})

export const getAnnualRegistrations = ({startYear, endYear}) => request.get('/api/user/annualRegistrations', {params: {startYear, endYear}})

export const userActivityByYear = ({startYear, endYear}) => request.get('/api/user/userActivityByYear', {params: {startYear, endYear}})

export const getPrivacySettingsById = (userId) => request.get('/api/user/getPrivacySettingsByUserId', {params: {userId}})